<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<html>
<head>
    <title>项目管理</title>
    <link type="text/css" rel="stylesheet" href="/static/bootstrap/css/bootstrap-datetimepicker.css">
    <script src="/static/bootstrap/js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
    <script src="/static/bootstrap/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
    <script>
        function cancel() {
            location.href = "/xg/";
        }

        function submitForm() {
            var income = $("#income").val();
            var expenditure = $("#expenditure").val();
            var projectDate = $("#projectDate").val();
            var project = $("#project").val();
            if (projectDate == '') {
                alert('请选择项目日期');
                $("#projectDate").focus();
                return;
            }
            if (project == '') {
                alert('请输入项目名称');
                $("#project").focus();
                return;
            }
            var reg = /^\d+(\.\d+)?$/i;
            if (!reg.test(income)) {
                alert('请输入正确的收入项');
                $("#income").focus();
                return;
            }

            if (!reg.test(expenditure)) {
                alert('请输入正确的支出项');
                $("#expenditure").focus();
                return;
            }
            $("#form").submit();
        }
    </script>
</head>
<body>
<div style="width: 70%;margin: auto">
    <form:form action="/xg/save" method="post" commandName="refrigerationDTO" id="form">
        <form:hidden path="id"/>
        <table class="table table-hover">
            <tr>
                <td>项目日期</td>
                <td><form:input path="date" date-date-format="yyyy-mm-dd" id="projectDate" readonly="true"
                                cssClass="form-control"/></td>
            </tr>
            <tr>
                <td>项目名称</td>
                <td><form:input path="project" id="project" cssClass="form-control" placeholder="请输入项目名称"/></td>
            </tr>
            <tr>
                <td>项目收入（￥）</td>
                <td><form:input path="income" id="income" cssClass="form-control" placeholder="请输入项目收入"/></td>
            </tr>
            <tr>
                <td>项目支出（￥）</td>
                <td><form:input path="expenditure" id="expenditure" cssClass="form-control" placeholder="请输入项目支出"/></td>
            </tr>
            <tr>
                <td>项目人员</td>
                <td>
                    <form:select path="excutorId" cssClass="form-control" items="${executorMaps}"/>
                </td>
            </tr>
            <tr>
                <td>操作</td>
                <td><input type="button" class="btn btn-primary" value="保存" onclick="submitForm()">&nbsp;
                    <input type="button" class="btn btn-info" value="取消" onclick="cancel()">
                </td>
            </tr>
        </table>
    </form:form>
</div>
<myScript>
    <script type="text/javascript">
        $("#projectDate").datetimepicker({
            language: 'zh-CN',
            weekStart: 7,
            todayBtn: 1,
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            forceParse: 0,
            showMeridian: 1,
            format: 'yyyy-mm-dd hh:ii:ss'
        });
    </script>
</myScript>
</body>
</html>
